<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>06_JS函数</title>
</head>
<body>
<script>
  function f1 (){
    console.log('f1函数被调用了');
  }
  f1();

  function f2 (n){
    console.log('f2函数被调用了');
    console.log(n);
  }
  f2(100);
  f2('你好');
  f2(true);

  function f3 (n1,n2){
    console.log('f3函数被调用了');
    console.log(n1+n2);
  }
  f3(100,200);
  f3(1,2,3,4);//f3函数只能接收2个参数，多余的参数会被忽略
  f3(1);//n2为undefined，结果为NaN

  function f4 (x,y){
    console.log('f4函数被调用了');
    return x + y;
  }
  var result = f4(100,200);
  console.log(result);
  console.log(f4(100,200));

  // 匿名函数自调用
  (function(){
    console.log('匿名函数被调用了');
  })();

  var f5 = function (){
    console.log('f5函数被调用了');
  }
  f5();
  console.log(f5);
  console.log(typeof f5);

  //箭头函数
  const f6 = () => {
    console.log('f6函数被调用了');
  }
  f6();
</script>
</body>
</html>
